import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { FindMoviesDto } from './dto/find-movies.dto';
import { Movie, MoviesDocument } from './schemas/movies.schemas';

@Injectable()
export class MoviesService {
    private limit:number = 3
    constructor(@InjectModel('movies') private movieModel: Model<MoviesDocument>) {}

    async findByPage(page:number): Promise<Movie[]> {
        return this.movieModel.find().skip((page-1)*this.limit).limit(this.limit).exec();
      }
}
